<extend name="Base:main" />
<block name="script">
	<link rel="stylesheet" href="__PUBLIC__/seller/css/validform.css" />
	<script src="__PUBLIC__/seller/js/Validform_v5.3.2.js"></script>
</block>
<block name="content">
     <div class="tpl-content-wrapper">
            <div class="tpl-content-page-title">
               订单详情
            </div>
            <ol class="am-breadcrumb">
                <li><a href="#" class="am-icon-home">首页</a></li>
                <li><a href="#">订单管理</a></li>
                <li class="am-active">订单详情</li>
            </ol>
            <div class="tpl-portlet-components">
              <div class="portlet-title" style="min-height: 60px!important;">
                  <eq name="val.express_send_type" value="1">
                      <div class="caption font-green bold">
                          <span class="am-icon-code"></span> 订单详情 <eq name="val.express_send_type" value="1">| >>在线发布物流</eq> <a href="{:U('Needs/lists' , array('ref'=>$needid['ref']))}"> <button class="am-btn am-btn-primary am-btn-sm" > 查看物流单 </button></a>
                      </div>
                  </eq>
                  <eq name="val.express_send_type" value="0">
                    <div class="caption font-green bold">
                        <span class="am-icon-code"></span> 订单详情<eq name="val.status" value="1">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<?php if( $val['pay_status'] >= 1 && $val['express_send_status'] < 2 ) : ?><button class="am-btn am-btn-primary am-btn-sm" menu="tip_menu" href="{:U('Order/remind' , array('id' => $val['id']))}" request_type="ajax" title="是否要提醒对方发货？"><span class="am-icon-bell-o"></span> 提醒发货 </button><?php else : ?><?php endif; ?><else /> <button class="am-btn am-btn-default am-btn-xs" type="button">未确认订单</button></eq>
                    </div>
                  </eq>
                    <?php if( !$val['pay_status'] ) : ?>
                    <div class="timespan" style=" height:36px; line-height:36px; float:left"></div>
					<script>
						var starttime = new Date("{:date('Y-m-d H:i:s' , strtotime($val['create_time']) + 1800)}");
						var dingshi = setInterval(function () {
							var nowtime = new Date();
							var time = starttime - nowtime;
							if( time <= 0 ) {
								$('.timespan').html("订单已取消");
								$('#pay_status').html("--");
								clearInterval(dingshi);
							} else {
								var minute = parseInt(time / 1000 / 60 % 60);
								var seconds = parseInt(time / 1000 % 60);
								$('.timespan').html( "距离自动取消订单还有："+minute + "分钟" + seconds + "秒" );
							}
						}, 1000);
                    </script>
                    <?php endif; ?>
                   <div class="tpl-portlet-input tpl-fz-ml">
                        <div class="portlet-input input-inline">
                          
                            <span>订单编号:</span>
                            <span style="color: #dd5a43 !important;">{$val.ref}</span>
                            <br>
                            <span class="invoice-info-label">订单日期:</span>
                            <span style="color: #478fca !important;">{$val.date_order}</span>
                        </div>
                    </div>
                     <div class="tpl-portlet-input tpl-fz-ml">
                        <div class="portlet-input  input-inline">
                           
                                <a href="javascript:printme()" target="_self">
                                        <i class="icon-print">打印订单</i>
                                </a>
                         
                         </div>
                    </div>
                   


                </div>
              	<style>
                    .contect_list_info{ width:93%; margin-top:10px; }
                    .contect_list_info dl{ width:100%; float:left;font-size:14px; margin:0px; border-bottom:1px dashed #ccc;word-break: break-all; word-wrap:break-word;-webkit-box-flex: 1; overflow:hidden;}
                    .contect_list_info dl dt{ width:100px; float:left; color:#666;line-height:230%; text-align:right}
                    .contect_list_info dl dd{color:#999;line-height:220%; text-indent:1em;}
					dt+dd{ margin-top:0px !important;}
                    .list_width{ width:50% !important; }
					.am-table>tbody>tr>td, .am-table>tbody>tr>th, .am-table>tfoot>tr>td, .am-table>tfoot>tr>th, .am-table>thead>tr>td, .am-table>thead>tr>th{vertical-align:middle !important}
				</style>
                
                <div class="tpl-block ">
                    <div class="am-g tpl-amazeui-form">
                        <div class="am-u-sm-12 am-u-md-6">
                            <div style="text-align: center;background-color: #3a87ad;">
                                   <b>订单基本信息</b> 
                           </div>
                           <div class='contect_list_info'>
                                <dl class="list_width">
                                        <dt>来源平台：</dt>
                                    <dd><empty name="platform_name">平台订单<else />{$platform_name}</empty></dd>
                                </dl>
                                <dl class="list_width">
                                        <dt>创建时间：</dt>
                                    <dd>&nbsp;{$val.create_time}</dd>
                                </dl>
                                <span style=" clear:both"></span>
                             </div>
			</div>
                        <div class="am-u-sm-12 am-u-md-6">
                            <div style="text-align: center;background-color: #82af6f;">
                                   <b>收货人信息</b>
                            </div>
                            <div class='contect_list_info'>
								<?php $receive_info = explode('|' , $val['receive_info']); ?>
                                <dl class="list_width">
                                        <dt>收货人姓名：</dt>
                                    <dd>&nbsp;{$receive_info[0]}</dd>
                                </dl>
                                <dl class="list_width">
                                        <dt>联系电话：</dt>
                                    <dd>&nbsp;{$receive_info[2]}</dd>
                                </dl>
                                <dl class="list_width">
                                        <dt>身份证号码：</dt>
                                    <dd>{$receive_info[1]}</dd>
                                </dl>
								<dl class="list_width">
                                        <dt>地区：</dt>
                                    <dd>{$receive_info[3]} - {$receive_info[4]} - {$receive_info[5]} - {$receive_info[6]}</dd>
                                </dl>
                                <dl>
                                        <dt>收货信息：</dt>
                                    <dd>&nbsp;{$receive_info[7]}</dd>
                                </dl>
                            </div>
                            
			</div>
                        
		    </div>
                     <div class="am-g" style="margin-top:20px;">
                        <div class="am-u-sm-12">
                            <table class="am-table am-table-bordered  table-main am-table-bordered am-table-radius">
                            <thead>
                                    <tr>
                                            <th>en13码</th>
                                            <th>名称</th>
                                            <th>单价</th>
                                            <th>供货价</th>
                                            <th>购买数量</th>
                                            <th>商品总价</th>
                                            <th>供应商</th>
                                        <eq name="val.express_send_type" value="1"><th>物流预算</th></eq>
                                        <eq name="val.express_send_type" value="0"><th>物流费</th></eq>
                                        <eq name="val.express_send_type" value="2"><th>线下物流</th></eq>
                                            <th>总金额</th>
                                            <th>支付金额</th>
                                            <th>是否发货</th>
                                            <th>物流提供方</th>
                                            <th>物流公司</th>
                                            <th>物流单号</th>
                                            <th>发货时间</th>
                                            <th>支付状态</th>
                                    </tr>
                            </thead>

                            <tbody>
                                <volist name="val.order_customer_line" id="vo">
                                	<foreach name="vo.list" item="vos" key="k">
                                    <?php if( $k <= 0 ) : ?>
										<tr>
											<td>{$vos.earn13}</td>
											<td>{$vos.name}</td>
											<td>{$vos.price}</td>
											<td>{$vos.supply_price}</td>
											<td>{$vos.num}</td>
											<td><?php echo $vos['supply_price'] * $vos['num']; ?></td>
											<td rowspan="<?php echo count($vo['list']); ?>">{$vo.supply_name}</td>
											<td rowspan="<?php echo count($vo['list']); ?>">{:sprintf("%.2f",$vo['fee']	)}</td>
											<td rowspan="<?php echo count($vo['list']); ?>">{:sprintf("%.2f",$vo['price_total'])}</td>
											<td rowspan="<?php echo count($vo['list']); ?>"><eq name="vo.surely_total" value="0">无<else/>{:sprintf("%.2f",$vo['surely_total'])}</eq></td>
											<td rowspan="<?php echo count($vo['list']); ?>">
											<?php if( ($vo['status'] == 2 && !$vo['surely_total']) || ($vo['status'] == 3)) { ?>
											<button id="menu_ok_souhuo" data-id="<?php echo $vo['ref'] . '_' . $vos['supply_customer_id']; ?>" class="am-btn am-btn-default am-btn-xs">确认收货</button>
											<script>
												$('#menu_ok_souhuo').click(function(){
													var _self = $(this);
													zeroModal.confirm("收货之后将不能进行退货操作，确认要收货？", function() {
														var load_write_index = waitload('正在请求，请稍后...');
														$.get(getUrl('Order/goodsReceipt' , { 'id' : _self.attr('data-id') } ) ,function( data ){
															zeroModal.close( load_write_index );
															if( data.status == 1 ) {
																success( data.info ,function(){
																	location.reload();
																});
															} else {
																error( data.info );
															}
														},'json');
													});
												});
											</script>
											<?php } else if( $vo['status'] == 1) { echo "等待发货"; } else if( $vo['status'] == 4) { echo "已收货"; } else { echo "等待支付"; } ?>
                                            </td>
											<td>
											<eq name="vos.dispatching_id" value="0">买家提供物流<else />卖家提供物流</eq>
											</td>
											<empty name="vo.express_name">
											<td rowspan="<?php echo count($vo['list']); ?>" valign="middle">-</td>
											<td rowspan="<?php echo count($vo['list']); ?>" valign="middle">-</td>
											<td rowspan="<?php echo count($vo['list']); ?>" valign="middle">-</td>
											<else />
											<td rowspan="<?php echo count($vo['list']); ?>" valign="middle">{$vo.express_name}</td>
											<td rowspan="<?php echo count($vo['list']); ?>" valign="middle">{$vo.express_no}</td>
											<td rowspan="<?php echo count($vo['list']); ?>" valign="middle">{:date('Y-m-d H:i:s' , $vo['send_time'])}</td>
											</empty>
                                            <td id="pay_status" rowspan="<?php echo count($vo['list']); ?>">
												<eq name="val.status" value="1">
													<?php if( in_array( $vo['status'] , array(0,2) ) && $vo['surely_total'] > 0 ) { ?>
													<button href="{:U('pay',array('ref'=>$vo['ref'] . '_' . $vos['supply_customer_id']))}" id="pay_cusomter" width="600" height="265" menu="load_iframe_url" class="am-btn am-btn-default am-btn-xs">立即支付</button>
													<?php } else { ?>
													<switch name="vo.status">
														<case value="8">退款失败</case>
														<case value="9">退款成功</case>
														<default />已支付</case>
													</switch>
													<?php } ?>
												<else />
													--
												</eq></td>
                                        </tr>
                                    <?php else : ?>
										<tr>
                                            <td>{$vos.earn13}</td>
                                            <td>{$vos.name}</td>
                                            <td>{$vos.price}</td>
                                            <td>{$vos.supply_price}</td>
                                            <td>{$vos.num}</td>
                                            <td><?php echo $vos['supply_price'] * $vos['num']; ?></td>
                              			</tr>
                                    <?php endif; ?>
                                    </foreach>
                                </volist>															
							</tbody>
                            </table>
                            </div>
                         </div>
                    <style>
                        .hr {
                            display: block;
                            height: 0;
                            overflow: hidden;
                            font-size: 0;
                            border-width: 1px 0 0 0;
                            border-top: 1px solid #E3E3E3;
                            margin: 12px 0;
                            border-top-color: rgba(0, 0, 0, 0.11);
                          }
                          .hr-double {
                            height: 3px;
                            border-top: 1px solid #E3E3E3;
                            border-bottom: 1px solid #E3E3E3;
                            border-top-color: rgba(0, 0, 0, 0.11);
                            border-bottom-color: rgba(0, 0, 0, 0.11);
                          }
                          .hr-8,
                            .hr8 {
                              margin: 8px 0;
                            }
                          .hr.dotted,.hr-dotted {
                            border-style: dotted;
                          }
                    </style>
                    <div class="hr hr8 hr-double hr-dotted"></div>
                    <div class="tpl-portlet-input tpl-fz-ml">
                        <div class="portlet-input  input-inline">
                            <eq name="val.express_send_type" value="1"><span>物流预算:</span></eq>
                            <eq name="val.express_send_type" value="0"><span>物流费:</span></eq>
                            <eq name="val.express_send_type" value="2"><span>线下物流:</span></eq>
                                <span style="color: #478fca !important;">
                                    <eq name="val.delivery_fee" value="0"> 包邮<else /> ${:sprintf("%.2f",$val['delivery_fee'])} 元</eq><br>
                                    <neq name="val.discount" value="0">优惠金额 ： ${:sprintf("%.2f",$val['discount'])}<br></neq></span>
                                <span class="invoice-info-label">订单总价:</span>
                                <span style="color: #dd5a43 !important;">${:sprintf("%.2f",$val['amount_total'])} 元<neq name="val.total_import_taxes" value="0">(已含税：{:sprintf("%.2f",$val['total_import_taxes'])}元)</span> 

                         </div>
                    </div>
                    <neq name="val.platform_id" value="0">
                    <style>
                        .pay_ment_info{ width:100%; margin-top: 40px; }
                        .pay_ment_info dl dt{ width:100%; height:40px; line-height:40px; font-size:16px; border-bottom:1px solid #ccc; text-indent:10px;}
                        .pay_ment_info dl dd{ float:left; line-height:220%; width:100%; text-indent:20px; color:#666 }
                        .pay_ment_info dl dd span{ color:#333; }
                    </style>
                  
                    <div class="pay_ment_info">
                        <dl>
                            <dt>支付信息</dt>
                            <dd><span>是否支付：</span><eq name="val.state" value="0"><span style="color:red">未支付</span><else />已支付</eq></dd>
                            <eq name="val.state" value="1">
                            <dd><span>支付方式：</span>
                                <switch name="val.order_payment.payment_account">
                                        <case value="weixin">微信</case>
                                        <case value="alipay">支付宝</case>
                                        <case value="pcupacp">银联</case>
                                </switch>
                            </dd>
                            <dd><span>支付金额：</span>{$val.order_payment.payamount}</dd>
                            <dd><span>支付流水号：</span>{$val.order_payment.payment_no}</dd>
                            <dd><span>支付成功时间：</span>{$val.order_payment.create_time}</dd>
                        </dl>
                    </div>
                    </neq>
	        </div>
	    </div>
    </div>
    <script>
           function send_notify() {
                zeroModal.closeAll();
                location.reload();
            }

            function pay_notify() {
                zeroModal.closeAll();
                zeroModal.confirm({
                    content: '支付成功了吗？',
                    buttons: [
                        { className: 'zeromodal-btn zeromodal-btn-primary', name: '支付成功', fn:function(opt){ location.reload() }},
                        { className: 'zeromodal-btn zeromodal-btn-default', name: '失败了', fn:function(opt){ $('#pay_cusomter').click(); }}
                    ]
                });
            }
    </script>
</block>

